package 最短距离;

import java.util.Arrays;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class Main {
    static int N = 100010, M = 300010, n, m, idx;
    static int[] h = new int[N];
    static int[] e = new int[M];
    static int[] w = new int[M];
    static int[] ne = new int[M];
    static boolean[] st = new boolean[N];
    static int[] dist = new int[N];

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();
        Arrays.fill(h, -1);
        Arrays.fill(dist, Integer.MAX_VALUE);
        for (int i = 0; i < m; i++) {
            int a = in.nextInt();
            int b = in.nextInt();
            int c = in.nextInt();
            add(a, b, c);
            add(b, a, c);
        }
        int k = in.nextInt();
        while (k-- > 0) {
            int x = in.nextInt();
            add(0, x, 0);
        }
        spfa();
        int q = in.nextInt();
        while (q-- > 0) {
            int x = in.nextInt();
            System.out.println(dist[x]);
        }
    }

    private static void spfa() {
        Queue<Integer> q = new LinkedList<>();
        q.offer(0);
        st[0] = true;
        dist[0] = 0;
        while (!q.isEmpty()) {
            int x = q.poll();
            st[x] = false;
            for (int i = h[x]; i != -1; i = ne[i]) {
                int j = e[i];
                if (dist[j] > dist[x] + w[i]) {
                    dist[j] = dist[x] + w[i];
                    if (!st[j]) {
                        st[j] = true;
                        q.offer(j);
                    }
                }
            }
        }
    }

    private static void add(int a, int b, int c) {
        e[idx] = b;
        w[idx] = c;
        ne[idx] = h[a];
        h[a] = idx++;
    }
}